#!/bin/sh
#
# About
# -----
# Flush the system's firewall - leaving the host defenseless.
#
#
# License
# -------
#
# Copyright (c) 2013 by Steve Kemp.  All rights reserved.
#
# This script is free software; you can redistribute it and/or modify it under
# the same terms as Perl itself.
#
# The LICENSE file contains the full text of the license.
#
#


PATH=/usr/sbin:/sbin:/bin:/usr/bin

#
#  If we're root we don't use sudo.
#
if [ "$(id -ru)" = 0 ]; then
    SUDO=""
else
    SUDO="sudo"
fi


#
# Define default policies of ACCEPT.
#
$SUDO iptables -P INPUT ACCEPT
$SUDO ip6tables -P INPUT ACCEPT

$SUDO iptables -P OUTPUT ACCEPT
$SUDO ip6tables -P OUTPUT ACCEPT

$SUDO iptables -P FORWARD ACCEPT
$SUDO ip6tables -P FORWARD ACCEPT

#
# Delete all existing rules, first
# IPv4 then IPv6.
#
$SUDO iptables -F
$SUDO ip6tables -F

$SUDO iptables -t nat -F
$SUDO ip6tables -t nat -F

$SUDO iptables -t mangle -F
$SUDO ip6tables -t mangle -F

$SUDO iptables -X
$SUDO ip6tables -X

